package com.itserver.controller.article;


import com.itserver.pojo.PageResult;
import com.itserver.pojo.Result;
import com.itserver.pojo.article.ArticleCate;
import com.itserver.pojo.article.QueryArticleCate;
import com.itserver.service.article.ArticleCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/articleCate")
public class ArticleCateController {

    @Autowired
    private ArticleCateService articleCateService;

    @GetMapping
    public Result list(QueryArticleCate params) {
        PageResult<ArticleCate> pageResult = articleCateService.list(params);
        return Result.success(pageResult);
    }

    @PostMapping
    public Result add(@RequestBody ArticleCate articleCate){
        articleCateService.add(articleCate);
        return Result.success();
    }

    @DeleteMapping
    public Result delete(@RequestParam List<Integer> ids){
        articleCateService.deleteById(ids);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody ArticleCate articleCate){
        articleCateService.update(articleCate);
        return Result.success();
    }
}
